<template>
  <div class="beijing">
    <div class="ai">
      <el-form label-width="100px" :model="biaodan" style="max-width: 460px">
        <el-form-item label="账号">
          <el-input v-model="biaodan.name" />
        </el-form-item>
        <el-form-item label="密码">
          <el-input show-password v-model="biaodan.region" />
        </el-form-item>
      </el-form>
      <div class="anniu">
        <el-button type="primary" @click="onSubmit">登录</el-button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { apis } from '@/http/api';
import { useRoute, useRouter } from 'vue-router';
const route: any = useRoute(); //等价于 this.$store

const biaodan = reactive({
  name: '',
  region: '',
});
const router = useRouter();
const onSubmit = () => {
  console.log(biaodan.name, biaodan.region);

  const qq = apis
    .getdenglu(biaodan.name, biaodan.region)
    .then(({ data: res }) => {
      console.log(res);
      let a: string = res.token;
      sessionStorage.setItem('token', a);
      console.log(a);
      router.replace(route.query.redirect);
    });
  console.log(qq);
};

// //获取数据
// onMounted(() => {
//   huoqu();
// });
// //获取首页左侧数据列表
// const list = reactive({
//   object: null as any,
// });

// const huoqu = () => {
//   const a = apis.getshouye().then(({ data: res }) => {
//     console.log(res);
//     list.object = res;
//   });
// };
</script>

<style lang="less" scoped>
.ai {
  width: 400px;
  padding: 5px;
  box-sizing: border-box;
  margin: 50px auto;
  .anniu {
    width: 61px;
    margin: auto;
  }
}
</style>
